package jwj.swing.component;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTabbedPane;
import javax.swing.JButton;
import javax.swing.JTextPane;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.ImageIcon;


// JTabbedPane
// 여러가지 컴퍼넌트들을 그룹화해서 각각의 탭으로 만든 후 클릭하면 표시하는 컴퍼넌트
// 한 화면에서 탭으로 전환하면서 많은 영역을 표시할 수 있어 편리함

public class J23_AdvancedComponent extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					J23_AdvancedComponent frame = new J23_AdvancedComponent();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public J23_AdvancedComponent() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 600, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		// 탭페인 생성		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		contentPane.add(tabbedPane, BorderLayout.CENTER);
		
		// 탭페인에 패널 추가
		JPanel panel = new JPanel();
		
		// 탭페인에 패널 추가 (addTab)
		tabbedPane.addTab("New tab", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/menu/user.png")), panel, null);
		
		JButton btnNewButton = new JButton("New button");
		panel.add(btnNewButton);
		
		JPanel panel_1 = new JPanel();
		tabbedPane.addTab("New tab", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/menu/play.png")), panel_1, null);
		
		textField = new JTextField();
		panel_1.add(textField);
		textField.setColumns(10);
		
		JPanel panel_2 = new JPanel();
		tabbedPane.addTab("New tab", new ImageIcon(J23_AdvancedComponent.class.getResource("/img/menu/paste.png")), panel_2, null);
		
		JRadioButton rdbtnNewRadioButton = new JRadioButton("New radio button");
		panel_2.add(rdbtnNewRadioButton);
	}

}
